
<template>
  <views class="facilitator_account_query">
    <viewTitle :title="'账户详情'" :border="false"></viewTitle>
    <!-- 搜索栏  企业端-代理商端-服务商端 -->
    <div class="search flex flexC">
      <!-- 客户编号-客户名称 -->
      <el-form ref="form" label-width="auto" :inline="true">
      <div class="search_input flex flexR center">
        <div class="their_facilitator flex flexR center">
          <el-form-item label="客户编号:">
            <el-input v-model="form.enterprise_sn" placeholder="请输入业务订单号" :clearable="true"></el-input>
          </el-form-item>
        </div>
        <div class="bank_statement flex flexR center">
          <el-form-item label="客户名称:">
          <el-input v-model="form.enterprise_name" placeholder="请输入客户名称" :clearable="true"></el-input>
          </el-form-item>
        </div>
        <!-- 按钮（查询、重置）   -->    
        <el-form-item >
        <div class="flex flexR pay_btn_list">
          <el-button type="primary" @click="getData">查询</el-button>
          <el-button @click="reset">重置</el-button>
        </div>
        </el-form-item>
      </div>
      </el-form>
    </div>
    <!-- 展示列表 -->
    <div class="table_list">
      <el-table
        border
        :data="tableData"
        style="width: 100%;max-width:none;"
        :header-cell-style="getRowClass"
        :select-on-indeterminate="true"
        :fit="true"
        :lazy="true"
        @row-click="clickRow"
        max-height="450"
      >
        <el-table-column fixed type="index" label="序号" width="100"></el-table-column>
        <el-table-column fixed prop="enterprise_sn" label="客户编号" width="250"></el-table-column>
        <el-table-column prop="enterprise_name" label="客户名称" width="auto"></el-table-column>
        <el-table-column prop="account_balance" label="总额度" width="200"></el-table-column>
        <el-table-column prop="avi_balance" label="可用额度" width="200"></el-table-column>
        <el-table-column prop="freeze_balance" label="冻结额度" width="200"></el-table-column>
        <el-table-column prop="zip" label="操作" fixed="right" width="200">
          <div class="table_operation " slot-scope="scope">
               <el-button type="primary" @click="to_detail(scope)">详情</el-button>
          </div>
        </el-table-column>
      </el-table>
    </div>
    <div class="flex flexR paging">
    <el-pagination
            style="background:#fff; padding:10px 0"
            background
            layout="total, sizes,prev, pager, next, jumper"
            @size-change="(page_size) => {this.pagination.page_size = page_size;this.getData()}"
            @current-change="(page_size) => {this.pagination.page_start = page_size;this.getData()}"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="pagination.page_size"
            :total="pagination.total_count"
            :current-page="pagination.current_page"
            :page-count="pagination.page_count">
    </el-pagination>
    </div>
  </views>
</template>



<script>
export default {
  data() {
    return {
      //  三段综合  企业端  代理商端  服务商端
      form: {
          enterprise_sn: "", //  客户编号
          enterprise_name: "", //  客户名称
      },
      pagination:{
          page_start:0,           //搜索开始页码
          current_page:0,         //当前页码
          page_count:0,           //总页数
          page_size:10,            //每页数量
          total_count:0           //总数量
      },
      tableData: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  mounted() {
      this.getData()
  },
  methods: {
    //    修改第一行样式
    getRowClass({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background: #FAFAFA ";
      } else {
        return "";
      }
    },
    //     点击单行
    clickRow(row, column, event) {
      console.log(row, column, event);
    },
    //    修改是否换行
    changeStyleRow(width) {
      let _width = width - 290 - 350 - 300 - 50 - 25;
      if (_width > 300) {
        this.marginLeft = 25;
      } else {
        this.marginLeft = 0;
      }
    },
    // 去账户详情
    to_detail(scope){
        console.log('scope', scope);
        this.$toRoutePath({
        path: "/my_account/my_account_detail",
        edit: true,
        query: {enterprise_id:scope.row.enterprise_id}
      });
    },
    //  搜索/查询
    getData() {
      this.form.pagination = this.pagination;
      let {code , msg, data} = this.$api.sendSync( this.$mapapi.ffaccountList, this.form);
      if(code != 200&&code!=501){
          this.$message.error(msg);
          this.tableData = [];
          return;
      }
      this.download_url = data.download_url;
      this.tableData = data.list;
      this.pagination = data.pagination;
    },
    //  重置
    reset() {
          this.form.enterprise_sn= ""; //  客户编号
          this.form.enterprise_name=""; //  客户名称
          this.getData();
    }
  },
  created() {}
};
</script>


<style lang="less" :scope="true"  src="@/style/account/facilitator_account_query.less" >
</style>